<!DOCTYPE html><html><head>
      <title>Mysql</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      
      <link rel="stylesheet" href="file:///C:\Users\Python\.vscode\extensions\shd101wyy.markdown-preview-enhanced-0.4.3\node_modules\@shd101wyy\mume\dependencies\katex\katex.min.css">
      
      

      
      
      
      
      
      

      <style>
      /**
 * prism.js Github theme based on GitHub's theme.
 * @author Sam Clarke
 */
code[class*="language-"],
pre[class*="language-"] {
  color: #333;
  background: none;
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.4;

  -moz-tab-size: 8;
  -o-tab-size: 8;
  tab-size: 8;

  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

/* Code blocks */
pre[class*="language-"] {
  padding: .8em;
  overflow: auto;
  /* border: 1px solid #ddd; */
  border-radius: 3px;
  /* background: #fff; */
  background: #f5f5f5;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
  padding: .1em;
  border-radius: .3em;
  white-space: normal;
  background: #f5f5f5;
}

.token.comment,
.token.blockquote {
  color: #969896;
}

.token.cdata {
  color: #183691;
}

.token.doctype,
.token.punctuation,
.token.variable,
.token.macro.property {
  color: #333;
}

.token.operator,
.token.important,
.token.keyword,
.token.rule,
.token.builtin {
  color: #a71d5d;
}

.token.string,
.token.url,
.token.regex,
.token.attr-value {
  color: #183691;
}

.token.property,
.token.number,
.token.boolean,
.token.entity,
.token.atrule,
.token.constant,
.token.symbol,
.token.command,
.token.code {
  color: #0086b3;
}

.token.tag,
.token.selector,
.token.prolog {
  color: #63a35c;
}

.token.function,
.token.namespace,
.token.pseudo-element,
.token.class,
.token.class-name,
.token.pseudo-class,
.token.id,
.token.url-reference .token.variable,
.token.attr-name {
  color: #795da3;
}

.token.entity {
  cursor: help;
}

.token.title,
.token.title .token.punctuation {
  font-weight: bold;
  color: #1d3e81;
}

.token.list {
  color: #ed6a43;
}

.token.inserted {
  background-color: #eaffea;
  color: #55a532;
}

.token.deleted {
  background-color: #ffecec;
  color: #bd2c00;
}

.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}


/* JSON */
.language-json .token.property {
  color: #183691;
}

.language-markup .token.tag .token.punctuation {
  color: #333;
}

/* CSS */
code.language-css,
.language-css .token.function {
  color: #0086b3;
}

/* YAML */
.language-yaml .token.atrule {
  color: #63a35c;
}

code.language-yaml {
  color: #183691;
}

/* Ruby */
.language-ruby .token.function {
  color: #333;
}

/* Markdown */
.language-markdown .token.url {
  color: #795da3;
}

/* Makefile */
.language-makefile .token.symbol {
  color: #795da3;
}

.language-makefile .token.variable {
  color: #183691;
}

.language-makefile .token.builtin {
  color: #0086b3;
}

/* Bash */
.language-bash .token.keyword {
  color: #0086b3;
}

/* highlight */
pre[data-line] {
  position: relative;
  padding: 1em 0 1em 3em;
}
pre[data-line] .line-highlight-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  background-color: transparent;
  display: block;
  width: 100%;
}

pre[data-line] .line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  padding: inherit 0;
  margin-top: 1em;
  background: hsla(24, 20%, 50%,.08);
  background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
  pointer-events: none;
  line-height: inherit;
  white-space: pre;
}

pre[data-line] .line-highlight:before, 
pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-start);
  position: absolute;
  top: .4em;
  left: .6em;
  min-width: 1em;
  padding: 0 .5em;
  background-color: hsla(24, 20%, 50%,.4);
  color: hsl(24, 20%, 95%);
  font: bold 65%/1.5 sans-serif;
  text-align: center;
  vertical-align: .3em;
  border-radius: 999px;
  text-shadow: none;
  box-shadow: 0 1px white;
}

pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-end);
  top: auto;
  bottom: .4em;
}html body{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ul,html body>ol{margin-bottom:16px}html body ul,html body ol{padding-left:2em}html body ul.no-list,html body ol.no-list{padding:0;list-style-type:none}html body ul ul,html body ul ol,html body ol ol,html body ol ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:bold;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em !important;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::before,html body code::after{letter-spacing:-0.2em;content:"\00a0"}html body pre>code{padding:0;margin:0;font-size:.85em !important;word-break:normal;white-space:pre;background:transparent;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;font-size:.85em !important;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:before,html body pre tt:before,html body pre code:after,html body pre tt:after{content:normal}html body p,html body blockquote,html body ul,html body ol,html body dl,html body pre{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body pre,html body code{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .pagebreak,.markdown-preview .newpage{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center !important}.markdown-preview:not([for="preview"]) .code-chunk .btn-group{display:none}.markdown-preview:not([for="preview"]) .code-chunk .status{display:none}.markdown-preview:not([for="preview"]) .code-chunk .output-div{margin-bottom:16px}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{font-size:14px !important;padding:1em}}@media print{html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,0.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{padding:0 1.6em;margin-top:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc li{margin-bottom:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{list-style-type:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% -  300px);padding:2em calc(50% - 457px -  150px);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */

      </style>
    </head>
    <body for="html-export">
      <div class="mume markdown-preview  ">
      <h1>MySQL&#x6570;&#x636E;&#x5E93;</h1>
<table>
<thead>
<tr>
<th>Tedu Python &#x6559;&#x5B66;&#x90E8;</th>
</tr>
</thead>
<tbody>
<tr>
<td>Author&#xFF1A;&#x5415;&#x6CFD;</td>
</tr>
</tbody>
</table>
<hr>
<ul>
<li><a href="#%E6%95%B0%E6%8D%AE%E5%BA%93%E6%A6%82%E8%BF%B0">&#x6570;&#x636E;&#x5E93;&#x6982;&#x8FF0;</a>
<ul>
<li><a href="#%E6%95%B0%E6%8D%AE%E5%AD%98%E5%82%A8%E9%98%B6%E6%AE%B5">&#x6570;&#x636E;&#x5B58;&#x50A8;&#x9636;&#x6BB5;</a></li>
<li><a href="#%E6%95%B0%E6%8D%AE%E5%BA%93%E5%BA%94%E7%94%A8">&#x6570;&#x636E;&#x5E93;&#x5E94;&#x7528;</a></li>
<li><a href="#%E5%9F%BA%E7%A1%80%E6%A6%82%E5%BF%B5">&#x57FA;&#x7840;&#x6982;&#x5FF5;</a></li>
<li><a href="#%E6%95%B0%E6%8D%AE%E5%BA%93%E5%88%86%E7%B1%BB%E5%92%8C%E5%B8%B8%E8%A7%81%E6%95%B0%E6%8D%AE%E5%BA%93">&#x6570;&#x636E;&#x5E93;&#x5206;&#x7C7B;&#x548C;&#x5E38;&#x89C1;&#x6570;&#x636E;&#x5E93;</a></li>
<li><a href="#%E8%AE%A4%E8%AF%86%E5%85%B3%E7%B3%BB%E5%9E%8B%E6%95%B0%E6%8D%AE%E5%BA%93%E5%92%8Cmysql">&#x8BA4;&#x8BC6;&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;&#x548C;MySQL</a></li>
</ul>
</li>
<li><a href="#sql%E8%AF%AD%E5%8F%A5">SQL&#x8BED;&#x53E5;</a></li>
<li><a href="#mysql-%E6%95%B0%E6%8D%AE%E5%BA%93%E6%93%8D%E4%BD%9C">MySQL &#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;</a>
<ul>
<li><a href="#%E6%95%B0%E6%8D%AE%E5%BA%93%E6%93%8D%E4%BD%9C">&#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;</a></li>
<li><a href="#%E6%95%B0%E6%8D%AE%E8%A1%A8%E7%9A%84%E7%AE%A1%E7%90%86">&#x6570;&#x636E;&#x8868;&#x7684;&#x7BA1;&#x7406;</a></li>
</ul>
</li>
<li><a href="#%E6%95%B0%E6%8D%AE%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C">&#x6570;&#x636E;&#x57FA;&#x672C;&#x64CD;&#x4F5C;</a>
<ul>
<li><a href="#%E6%8F%92%E5%85%A5insert">&#x63D2;&#x5165;(insert)</a></li>
<li><a href="#%E6%9F%A5%E8%AF%A2select">&#x67E5;&#x8BE2;(select)</a></li>
<li><a href="#where%E5%AD%90%E5%8F%A5">where&#x5B50;&#x53E5;</a>
<ul>
<li><a href="#%E7%AE%97%E6%95%B0%E8%BF%90%E7%AE%97%E7%AC%A6">&#x7B97;&#x6570;&#x8FD0;&#x7B97;&#x7B26;</a></li>
<li><a href="#%E6%AF%94%E8%BE%83%E8%BF%90%E7%AE%97%E7%AC%A6">&#x6BD4;&#x8F83;&#x8FD0;&#x7B97;&#x7B26;</a></li>
<li><a href="#%E9%80%BB%E8%BE%91%E8%BF%90%E7%AE%97%E7%AC%A6">&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;</a></li>
<li><a href="#%E4%BD%8D%E8%BF%90%E7%AE%97%E7%AC%A6">&#x4F4D;&#x8FD0;&#x7B97;&#x7B26;</a></li>
</ul>
</li>
<li><a href="#%E6%9B%B4%E6%96%B0%E8%A1%A8%E8%AE%B0%E5%BD%95update">&#x66F4;&#x65B0;&#x8868;&#x8BB0;&#x5F55;(update)</a></li>
<li><a href="#%E5%88%A0%E9%99%A4%E8%A1%A8%E8%AE%B0%E5%BD%95delete">&#x5220;&#x9664;&#x8868;&#x8BB0;&#x5F55;&#xFF08;delete&#xFF09;</a></li>
<li><a href="#%E8%A1%A8%E5%AD%97%E6%AE%B5%E7%9A%84%E6%93%8D%E4%BD%9Calter">&#x8868;&#x5B57;&#x6BB5;&#x7684;&#x64CD;&#x4F5C;(alter)</a></li>
<li><a href="#%E6%97%B6%E9%97%B4%E7%B1%BB%E5%9E%8B%E6%95%B0%E6%8D%AE">&#x65F6;&#x95F4;&#x7C7B;&#x578B;&#x6570;&#x636E;</a>
<ul>
<li><a href="#%E6%97%B6%E9%97%B4%E6%A0%BC%E5%BC%8F">&#x65F6;&#x95F4;&#x683C;&#x5F0F;</a></li>
<li><a href="#%E6%97%A5%E6%9C%9F%E6%97%B6%E9%97%B4%E5%87%BD%E6%95%B0">&#x65E5;&#x671F;&#x65F6;&#x95F4;&#x51FD;&#x6570;</a></li>
<li><a href="#%E6%97%B6%E9%97%B4%E6%93%8D%E4%BD%9C">&#x65F6;&#x95F4;&#x64CD;&#x4F5C;</a></li>
</ul>
</li>
<li><a href="#%E9%AB%98%E7%BA%A7%E6%9F%A5%E8%AF%A2%E8%AF%AD%E5%8F%A5">&#x9AD8;&#x7EA7;&#x67E5;&#x8BE2;&#x8BED;&#x53E5;</a>
<ul>
<li><a href="#%E6%A8%A1%E7%B3%8A%E6%9F%A5%E8%AF%A2%E5%92%8C%E6%AD%A3%E5%88%99%E6%9F%A5%E8%AF%A2">&#x6A21;&#x7CCA;&#x67E5;&#x8BE2;&#x548C;&#x6B63;&#x5219;&#x67E5;&#x8BE2;</a></li>
<li><a href="#%E6%8E%92%E5%BA%8F">&#x6392;&#x5E8F;</a></li>
<li><a href="#%E5%88%86%E9%A1%B5%E9%99%90%E5%88%B6">&#x5206;&#x9875;(&#x9650;&#x5236;)</a></li>
<li><a href="#%E8%81%94%E5%90%88%E6%9F%A5%E8%AF%A2">&#x8054;&#x5408;&#x67E5;&#x8BE2;</a></li>
</ul>
</li>
<li><a href="#%E6%95%B0%E6%8D%AE%E5%A4%87%E4%BB%BD">&#x6570;&#x636E;&#x5907;&#x4EFD;</a></li>
</ul>
</li>
<li><a href="#python%E6%93%8D%E4%BD%9Cmysql%E6%95%B0%E6%8D%AE%E5%BA%93">Python&#x64CD;&#x4F5C;MySQL&#x6570;&#x636E;&#x5E93;</a>
<ul>
<li><a href="#pymysql%E5%AE%89%E8%A3%85">pymysql&#x5B89;&#x88C5;</a></li>
<li><a href="#pymysql%E4%BD%BF%E7%94%A8%E6%B5%81%E7%A8%8B">pymysql&#x4F7F;&#x7528;&#x6D41;&#x7A0B;</a>
<ul>
<li><a href="#%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0">&#x5E38;&#x7528;&#x51FD;&#x6570;</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 class="mume-header" id="%E6%95%B0%E6%8D%AE%E5%BA%93%E6%A6%82%E8%BF%B0">&#x6570;&#x636E;&#x5E93;&#x6982;&#x8FF0;</h2>

<h3 class="mume-header" id="%E6%95%B0%E6%8D%AE%E5%AD%98%E5%82%A8%E9%98%B6%E6%AE%B5">&#x6570;&#x636E;&#x5B58;&#x50A8;&#x9636;&#x6BB5;</h3>

<p>&#x3010;1&#x3011; &#x4EBA;&#x5DE5;&#x7BA1;&#x7406;&#x9636;&#x6BB5;</p>
<p>&#x7F3A;&#x70B9; &#xFF1A;  &#x6570;&#x636E;&#x65E0;&#x6CD5;&#x5171;&#x4EAB;,&#x4E0D;&#x80FD;&#x5355;&#x72EC;&#x4FDD;&#x6301;,&#x6570;&#x636E;&#x5B58;&#x50A8;&#x91CF;&#x6709;&#x9650;</p>
<p>&#x3010;2&#x3011; &#x6587;&#x4EF6;&#x7BA1;&#x7406;&#x9636;&#x6BB5; &#xFF08;.txt  .doc  .xls&#xFF09;</p>
<p>&#x4F18;&#x70B9; &#xFF1A; &#x6570;&#x636E;&#x53EF;&#x4EE5;&#x957F;&#x671F;&#x4FDD;&#x5B58;,&#x53EF;&#x4EE5;&#x5B58;&#x50A8;&#x5927;&#x91CF;&#x7684;&#x6570;&#x636E;,&#x4F7F;&#x7528;&#x7B80;&#x5355;</p>
<p>&#x7F3A;&#x70B9; &#xFF1A;  &#x6570;&#x636E;&#x4E00;&#x81F4;&#x6027;&#x5DEE;,&#x6570;&#x636E;&#x67E5;&#x627E;&#x4FEE;&#x6539;&#x4E0D;&#x65B9;&#x4FBF;,&#x6570;&#x636E;&#x5197;&#x4F59;&#x5EA6;&#x53EF;&#x80FD;&#x6BD4;&#x8F83;&#x5927;</p>
<p>&#x3010;3&#x3011;&#x6570;&#x636E;&#x5E93;&#x7BA1;&#x7406;&#x9636;&#x6BB5;</p>
<p>&#x4F18;&#x70B9; &#xFF1A; &#x6570;&#x636E;&#x7EC4;&#x7EC7;&#x7ED3;&#x6784;&#x5316;&#x964D;&#x4F4E;&#x4E86;&#x5197;&#x4F59;&#x5EA6;,&#x63D0;&#x9AD8;&#x4E86;&#x589E;&#x5220;&#x6539;&#x67E5;&#x7684;&#x6548;&#x7387;,&#x5BB9;&#x6613;&#x6269;&#x5C55;,&#x65B9;&#x4FBF;&#x7A0B;&#x5E8F;&#x8C03;&#x7528;&#xFF0C;&#x505A;&#x81EA;&#x52A8;&#x5316;&#x5904;&#x7406;</p>
<p>&#x7F3A;&#x70B9; &#xFF1A;&#x9700;&#x8981;&#x4F7F;&#x7528;sql &#x6216;&#x8005; &#x5176;&#x4ED6;&#x7279;&#x5B9A;&#x7684;&#x8BED;&#x53E5;&#xFF0C;&#x76F8;&#x5BF9;&#x6BD4;&#x8F83;&#x590D;&#x6742;</p>
<h3 class="mume-header" id="%E6%95%B0%E6%8D%AE%E5%BA%93%E5%BA%94%E7%94%A8">&#x6570;&#x636E;&#x5E93;&#x5E94;&#x7528;</h3>

<blockquote>
<p>&#x878D;&#x673A;&#x6784;&#x3001;&#x6E38;&#x620F;&#x7F51;&#x7AD9;&#x3001;&#x8D2D;&#x7269;&#x7F51;&#x7AD9;&#x3001;&#x8BBA;&#x575B;&#x7F51;&#x7AD9; ... ...</p>
</blockquote>
<p><img src="img/%E6%95%B0%E6%8D%AE%E5%BA%93%E7%B3%BB%E7%BB%9F.png" alt></p>
<h3 class="mume-header" id="%E5%9F%BA%E7%A1%80%E6%A6%82%E5%BF%B5">&#x57FA;&#x7840;&#x6982;&#x5FF5;</h3>

<blockquote>
<p>&#x6570;&#x636E; &#xFF1A; &#x80FD;&#x591F;&#x8F93;&#x5165;&#x5230;&#x8BA1;&#x7B97;&#x673A;&#x4E2D;&#x5E76;&#x88AB;&#x8BC6;&#x522B;&#x5904;&#x7406;&#x7684;&#x4FE1;&#x606F;&#x96C6;&#x5408;</p>
</blockquote>
<blockquote>
<p>&#x6570;&#x636E;&#x7ED3;&#x6784; &#xFF1A;&#x7814;&#x7A76;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x96C6;&#x5408;&#x4E2D;&#x6570;&#x636E;&#x4E4B;&#x95F4;&#x5173;&#x7CFB;&#x7684;</p>
</blockquote>
<blockquote>
<p>&#x6570;&#x636E;&#x5E93; &#xFF1A; &#x6309;&#x7167;&#x6570;&#x636E;&#x7ED3;&#x6784;&#xFF0C;&#x5B58;&#x50A8;&#x7BA1;&#x7406;&#x6570;&#x636E;&#x7684;&#x4ED3;&#x5E93;&#x3002;&#x6570;&#x636E;&#x5E93;&#x662F;&#x5728;&#x6570;&#x636E;&#x5E93;&#x7BA1;&#x7406;&#x7CFB;&#x7EDF;&#x7BA1;&#x7406;&#x548C;&#x63A7;&#x5236;&#x4E0B;&#xFF0C;&#x5728;&#x4E00;&#x5B9A;&#x4ECB;&#x8D28;&#x4E0A;&#x7684;&#x6570;&#x636E;&#x96C6;&#x5408;&#x3002;</p>
</blockquote>
<blockquote>
<p>&#x6570;&#x636E;&#x5E93;&#x7BA1;&#x7406;&#x7CFB;&#x7EDF; &#xFF1A;&#x7BA1;&#x7406;&#x6570;&#x636E;&#x5E93;&#x7684;&#x8F6F;&#x4EF6;&#xFF0C;&#x7528;&#x4E8E;&#x5EFA;&#x7ACB;&#x548C;&#x7EF4;&#x62A4;&#x6570;&#x636E;&#x5E93;</p>
</blockquote>
<blockquote>
<p>&#x6570;&#x636E;&#x5E93;&#x7CFB;&#x7EDF; &#xFF1A; &#x7531;&#x6570;&#x636E;&#x5E93;&#x548C;&#x6570;&#x636E;&#x5E93;&#x7BA1;&#x7406;&#x7CFB;&#x7EDF;&#xFF0C;&#x5F00;&#x53D1;&#x5DE5;&#x5177;&#x7B49;&#x7EC4;&#x6210;&#x7684;&#x96C6;&#x5408;</p>
</blockquote>
<h3 class="mume-header" id="%E6%95%B0%E6%8D%AE%E5%BA%93%E5%88%86%E7%B1%BB%E5%92%8C%E5%B8%B8%E8%A7%81%E6%95%B0%E6%8D%AE%E5%BA%93">&#x6570;&#x636E;&#x5E93;&#x5206;&#x7C7B;&#x548C;&#x5E38;&#x89C1;&#x6570;&#x636E;&#x5E93;</h3>

<ul>
<li>&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;&#x548C;&#x975E;&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;</li>
</ul>
<blockquote>
<p>&#x5173;&#x7CFB;&#x578B;&#xFF1A; &#x91C7;&#x7528;&#x5173;&#x7CFB;&#x6A21;&#x578B;&#xFF08;&#x4E8C;&#x7EF4;&#x8868;&#xFF09;&#x6765;&#x7EC4;&#x7EC7;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x7684;&#x6570;&#x636E;&#x5E93;</p>
</blockquote>
<blockquote>
<p>&#x975E;&#x5173;&#x7CFB;&#x578B;&#xFF1A; &#x4E0D;&#x91C7;&#x7528;&#x5173;&#x7CFB;&#x6A21;&#x578B;&#x7EC4;&#x7EC7;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x7684;&#x6570;&#x636E;&#x5E93;</p>
</blockquote>
<ul>
<li>&#x5F00;&#x6E90;&#x6570;&#x636E;&#x5E93;&#x548C;&#x975E;&#x5F00;&#x6E90;&#x6570;&#x636E;&#x5E93;</li>
</ul>
<blockquote>
<p>&#x5F00;&#x6E90;&#xFF1A;MySQL&#x3001;SQLite&#x3001;MongoDB</p>
</blockquote>
<blockquote>
<p>&#x975E;&#x5F00;&#x6E90;&#xFF1A;Oracle&#x3001;DB2&#x3001;SQL_Server</p>
</blockquote>
<ul>
<li>&#x5E38;&#x89C1;&#x7684;&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;</li>
</ul>
<blockquote>
<p>MySQL&#x3001;Oracle&#x3001;SQL_Server&#x3001;DB2 SQLite</p>
</blockquote>
<h3 class="mume-header" id="%E8%AE%A4%E8%AF%86%E5%85%B3%E7%B3%BB%E5%9E%8B%E6%95%B0%E6%8D%AE%E5%BA%93%E5%92%8Cmysql">&#x8BA4;&#x8BC6;&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;&#x548C;MySQL</h3>

<ol>
<li>&#x6570;&#x636E;&#x5E93;&#x7ED3;&#x6784; &#xFF08;&#x56FE;&#x5E93;&#x7ED3;&#x6784;&#xFF09;</li>
</ol>
<blockquote>
<p>&#x6570;&#x636E;&#x5143;&#x7D20; --&gt; &#x8BB0;&#x5F55; --&gt;&#x6570;&#x636E;&#x8868; --&gt; &#x6570;&#x636E;&#x5E93;</p>
</blockquote>
<p><img src="img/%E5%BA%93%E7%BB%93%E6%9E%84.png" alt></p>
<ol start="2">
<li>&#x6570;&#x636E;&#x5E93;&#x6982;&#x5FF5;&#x89E3;&#x6790;</li>
</ol>
<blockquote>
<p>&#x6570;&#x636E;&#x8868; &#xFF1A; &#x5B58;&#x653E;&#x6570;&#x636E;&#x7684;&#x8868;&#x683C;</p>
</blockquote>
<blockquote>
<p>&#x5B57;&#x6BB5;&#xFF1A; &#x6BCF;&#x4E2A;&#x5217;&#xFF0C;&#x7528;&#x6765;&#x8868;&#x793A;&#x8BE5;&#x5217;&#x6570;&#x636E;&#x7684;&#x542B;&#x4E49;</p>
</blockquote>
<blockquote>
<p>&#x8BB0;&#x5F55;&#xFF1A; &#x6BCF;&#x4E2A;&#x884C;&#xFF0C;&#x8868;&#x793A;&#x4E00;&#x7EC4;&#x5B8C;&#x6574;&#x7684;&#x6570;&#x636E;</p>
</blockquote>
<p><img src="img/%E8%A1%A8%E7%BB%93%E6%9E%84.png" alt></p>
<ol start="3">
<li>MySQL&#x7279;&#x70B9;</li>
</ol>
<ul>
<li>&#x662F;&#x5F00;&#x6E90;&#x6570;&#x636E;&#x5E93;&#xFF0C;&#x4F7F;&#x7528;C&#x548C;C++&#x7F16;&#x5199;</li>
<li>&#x80FD;&#x591F;&#x5DE5;&#x4F5C;&#x5728;&#x4F17;&#x591A;&#x4E0D;&#x540C;&#x7684;&#x5E73;&#x53F0;&#x4E0A;</li>
<li>&#x63D0;&#x4F9B;&#x4E86;&#x7528;&#x4E8E;C&#x3001;C++&#x3001;Python&#x3001;Java&#x3001;Perl&#x3001;PHP&#x3001;Ruby&#x4F17;&#x591A;&#x8BED;&#x8A00;&#x7684;API</li>
<li>&#x5B58;&#x50A8;&#x7ED3;&#x6784;&#x4F18;&#x826F;&#xFF0C;&#x8FD0;&#x884C;&#x901F;&#x5EA6;&#x5FEB;</li>
<li>&#x529F;&#x80FD;&#x5168;&#x9762;&#x4E30;&#x5BCC;</li>
</ul>
<ol start="4">
<li>MySQL&#x5B89;&#x88C5;</li>
</ol>
<blockquote>
<p>Ubuntu&#x5B89;&#x88C5;MySQL&#x670D;&#x52A1;</p>
<blockquote>
<p>&#x5B89;&#x88C5;&#x670D;&#x52A1;&#x7AEF;: sudo apt-get install mysql-server<br>
&#x5B89;&#x88C5;&#x5BA2;&#x6237;&#x7AEF;: sudo apt-get install mysql-client</p>
<blockquote>
<p>&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF1A;/etc/mysql<br>
&#x547D;&#x4EE4;&#x96C6;&#xFF1A; /usr/bin<br>
&#x6570;&#x636E;&#x5E93;&#x5B58;&#x50A8;&#x76EE;&#x5F55; &#xFF1A;/var/lib/mysql</p>
</blockquote>
</blockquote>
</blockquote>
<blockquote>
<p>Windows&#x5B89;&#x88C5;MySQL</p>
<blockquote>
<p>&#x4E0B;&#x8F7D;MySQL&#x5B89;&#x88C5;&#x5305;(windows)  <a href="https://dev.mysql.com/downloads/mysql/">https://dev.mysql.com/downloads/mysql/</a><br>
mysql-installer***5.7.***.msi</p>
</blockquote>
<blockquote>
<p>&#x5B89;&#x88C5;&#x6559;&#x7A0B;&#x53BB;&#x5B89;&#x88C5;</p>
</blockquote>
</blockquote>
<ol start="5">
<li>&#x542F;&#x52A8;&#x548C;&#x8FDE;&#x63A5;MySQL&#x670D;&#x52A1;</li>
</ol>
<blockquote>
<p>&#x670D;&#x52A1;&#x7AEF;&#x542F;&#x52A8;</p>
<blockquote>
<p>&#x67E5;&#x770B;MySQL&#x72B6;&#x6001;: sudo /etc/init.d/mysql status<br>
&#x542F;&#x52A8;&#x670D;&#x52A1;&#xFF1A;sudo /etc/init.d/mysql start | stop | restart</p>
</blockquote>
</blockquote>
<blockquote>
<p>&#x5BA2;&#x6237;&#x7AEF;&#x8FDE;&#x63A5;</p>
<blockquote>
<p>&#x547D;&#x4EE4;&#x683C;&#x5F0F;</p>
<blockquote>
<p>mysql -h&#x4E3B;&#x673A;&#x5730;&#x5740; -u&#x7528;&#x6237;&#x540D; -p&#x5BC6;&#x7801;<br>
mysql -hlocalhost -uroot -p123456<br>
&#x672C;&#x5730;&#x8FDE;&#x63A5;&#x53EF;&#x7701;&#x7565; -h &#x9009;&#x9879;: mysql -uroot -p123456</p>
</blockquote>
</blockquote>
</blockquote>
<blockquote>
<p>&#x5173;&#x95ED;&#x8FDE;&#x63A5;</p>
<blockquote>
<p>ctrl-D<br>
exit</p>
</blockquote>
</blockquote>
<h2 class="mume-header" id="sql%E8%AF%AD%E5%8F%A5">SQL&#x8BED;&#x53E5;</h2>

<blockquote>
<p>&#x4EC0;&#x4E48;&#x662F;SQL</p>
<blockquote>
<p>&#x7ED3;&#x6784;&#x5316;&#x67E5;&#x8BE2;&#x8BED;&#x8A00;(Structured Query Language)&#xFF0C;&#x4E00;&#x79CD;&#x7279;&#x6B8A;&#x76EE;&#x7684;&#x7684;&#x7F16;&#x7A0B;&#x8BED;&#x8A00;&#xFF0C;&#x662F;&#x4E00;&#x79CD;&#x6570;&#x636E;&#x5E93;&#x67E5;&#x8BE2;&#x548C;&#x7A0B;&#x5E8F;&#x8BBE;&#x8BA1;&#x8BED;&#x8A00;&#xFF0C;&#x7528;&#x4E8E;&#x5B58;&#x53D6;&#x6570;&#x636E;&#x4EE5;&#x53CA;&#x67E5;&#x8BE2;&#x3001;&#x66F4;&#x65B0;&#x548C;&#x7BA1;&#x7406;&#x5173;&#x7CFB;&#x6570;&#x636E;&#x5E93;&#x7CFB;&#x7EDF;&#x3002;</p>
</blockquote>
</blockquote>
<blockquote>
<p>SQL&#x8BED;&#x53E5;&#x4F7F;&#x7528;&#x7279;&#x70B9;</p>
<ul>
<li>SQL&#x8BED;&#x8A00;&#x57FA;&#x672C;&#x4E0A;&#x72EC;&#x7ACB;&#x4E8E;&#x6570;&#x636E;&#x5E93;&#x672C;&#x8EAB;</li>
<li>&#x5404;&#x79CD;&#x4E0D;&#x540C;&#x7684;&#x6570;&#x636E;&#x5E93;&#x5BF9;SQL&#x8BED;&#x8A00;&#x7684;&#x652F;&#x6301;&#x4E0E;&#x6807;&#x51C6;&#x5B58;&#x5728;&#x7740;&#x7EC6;&#x5FAE;&#x7684;&#x4E0D;&#x540C;</li>
<li>&#x6BCF;&#x6761;&#x547D;&#x4EE4;&#x5FC5;&#x987B;&#x4EE5; ; &#x7ED3;&#x5C3E;</li>
<li>SQL&#x547D;&#x4EE4;&#x5173;&#x952E;&#x5B57;&#x4E0D;&#x533A;&#x5206;&#x5B57;&#x6BCD;&#x5927;&#x5C0F;&#x5199;</li>
</ul>
</blockquote>
<h2 class="mume-header" id="mysql-%E6%95%B0%E6%8D%AE%E5%BA%93%E6%93%8D%E4%BD%9C">MySQL &#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;</h2>

<h3 class="mume-header" id="%E6%95%B0%E6%8D%AE%E5%BA%93%E6%93%8D%E4%BD%9C">&#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;</h3>

<p>1.&#x67E5;&#x770B;&#x5DF2;&#x6709;&#x5E93;</p>
<blockquote>
<p>show databases;</p>
</blockquote>
<p>2.&#x521B;&#x5EFA;&#x5E93;(&#x6307;&#x5B9A;&#x5B57;&#x7B26;&#x96C6;)</p>
<blockquote>
<p>create database &#x5E93;&#x540D; [character set utf8];</p>
</blockquote>
<pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span> &#x521B;&#x5EFA;stu&#x6570;&#x636E;&#x5E93;&#xFF0C;&#x7F16;&#x7801;&#x4E3A;utf8
<span class="token keyword">create</span> <span class="token keyword">database</span> stu <span class="token keyword">character</span> <span class="token keyword">set</span> utf8<span class="token punctuation">;</span>
<span class="token keyword">create</span> <span class="token keyword">database</span> stu <span class="token keyword">charset</span><span class="token operator">=</span>utf8<span class="token punctuation">;</span>
</pre><p>3.&#x67E5;&#x770B;&#x521B;&#x5EFA;&#x5E93;&#x7684;&#x8BED;&#x53E5;(&#x5B57;&#x7B26;&#x96C6;)</p>
<blockquote>
<p>show create database &#x5E93;&#x540D;;</p>
</blockquote>
<pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span> &#x67E5;&#x770B;stu&#x521B;&#x5EFA;&#x65B9;&#x6CD5;
<span class="token keyword">show</span> <span class="token keyword">create</span> <span class="token keyword">database</span> stu<span class="token punctuation">;</span>
</pre><p>4.&#x67E5;&#x770B;&#x5F53;&#x524D;&#x6240;&#x5728;&#x5E93;</p>
<blockquote>
<p>select database();</p>
</blockquote>
<p>5.&#x5207;&#x6362;&#x5E93;</p>
<blockquote>
<p>use &#x5E93;&#x540D;;</p>
</blockquote>
<pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span> &#x4F7F;&#x7528;stu&#x6570;&#x636E;&#x5E93;
<span class="token keyword">use</span> stu<span class="token punctuation">;</span>
</pre><p>6.&#x5220;&#x9664;&#x5E93;</p>
<blockquote>
<p>drop database &#x5E93;&#x540D;;</p>
</blockquote>
<pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span> &#x5220;&#x9664;test&#x6570;&#x636E;&#x5E93;
<span class="token keyword">drop</span> <span class="token keyword">database</span> test<span class="token punctuation">;</span>
</pre><p>7.&#x5E93;&#x540D;&#x7684;&#x547D;&#x540D;&#x89C4;&#x5219;</p>
<blockquote>
<ul>
<li>&#x6570;&#x5B57;&#x3001;&#x5B57;&#x6BCD;&#x3001;&#x4E0B;&#x5212;&#x7EBF;,&#x4F46;&#x4E0D;&#x80FD;&#x4F7F;&#x7528;&#x7EAF;&#x6570;&#x5B57;</li>
<li>&#x5E93;&#x540D;&#x533A;&#x5206;&#x5B57;&#x6BCD;&#x5927;&#x5C0F;&#x5199;</li>
<li>&#x4E0D;&#x80FD;&#x4F7F;&#x7528;&#x7279;&#x6B8A;&#x5B57;&#x7B26;&#x548C;mysql&#x5173;&#x952E;&#x5B57;</li>
</ul>
</blockquote>
<h3 class="mume-header" id="%E6%95%B0%E6%8D%AE%E8%A1%A8%E7%9A%84%E7%AE%A1%E7%90%86">&#x6570;&#x636E;&#x8868;&#x7684;&#x7BA1;&#x7406;</h3>

<ol>
<li>
<p>&#x8868;&#x7ED3;&#x6784;&#x8BBE;&#x8BA1;&#x521D;&#x6B65;</p>
<p>&#x3010;1&#x3011; &#x5206;&#x6790;&#x5B58;&#x50A8;&#x5185;&#x5BB9;<br>
&#x3010;2&#x3011; &#x786E;&#x5B9A;&#x5B57;&#x6BB5;&#x6784;&#x6210;<br>
&#x3010;3&#x3011; &#x8BBE;&#x8BA1;&#x5B57;&#x6BB5;&#x7C7B;&#x578B;</p>
</li>
<li>
<p>&#x6570;&#x636E;&#x7C7B;&#x578B;&#x652F;&#x6301;</p>
</li>
</ol>
<blockquote>
<p>&#x6570;&#x5B57;&#x7C7B;&#x578B;&#xFF1A;</p>
<blockquote>
<p>&#x6574;&#x6570;&#x7C7B;&#x578B;&#xFF08;&#x7CBE;&#x786E;&#x503C;&#xFF09; - INTEGER&#xFF0C;INT&#xFF0C;SMALLINT&#xFF0C;TINYINT&#xFF0C;MEDIUMINT&#xFF0C;BIGINT<br>
&#x5B9A;&#x70B9;&#x7C7B;&#x578B;&#xFF08;&#x7CBE;&#x786E;&#x503C;&#xFF09; - DECIMAL<br>
&#x6D6E;&#x70B9;&#x7C7B;&#x578B;&#xFF08;&#x8FD1;&#x4F3C;&#x503C;&#xFF09; - FLOAT&#xFF0C;DOUBLE<br>
&#x6BD4;&#x7279;&#x503C;&#x7C7B;&#x578B; - BIT</p>
</blockquote>
</blockquote>
<p><img src="img/%E6%95%B4%E5%9E%8B.png" alt></p>
<blockquote>
<p>&#x5BF9;&#x4E8E;&#x7CBE;&#x5EA6;&#x6BD4;&#x8F83;&#x9AD8;&#x7684;&#x4E1C;&#x897F;&#xFF0C;&#x6BD4;&#x5982;money&#xFF0C;&#x7528;decimal&#x7C7B;&#x578B;&#x63D0;&#x9AD8;&#x7CBE;&#x5EA6;&#x51CF;&#x5C11;&#x8BEF;&#x5DEE;&#x3002;&#x5217;&#x7684;&#x58F0;&#x660E;&#x8BED;&#x6CD5;&#x662F;DECIMAL(M,D)&#x3002;</p>
<blockquote>
<p>M&#x662F;&#x6570;&#x5B57;&#x7684;&#x6700;&#x5927;&#x4F4D;&#x6570;&#xFF08;&#x7CBE;&#x5EA6;&#xFF09;&#x3002;&#x5176;&#x8303;&#x56F4;&#x4E3A;1&#xFF5E;65&#xFF0C;M &#x7684;&#x9ED8;&#x8BA4;&#x503C;&#x662F;10&#x3002;<br>
D&#x662F;&#x5C0F;&#x6570;&#x70B9;&#x53F3;&#x4FA7;&#x6570;&#x5B57;&#x7684;&#x6570;&#x76EE;&#xFF08;&#x6807;&#x5EA6;&#xFF09;&#x3002;&#x5176;&#x8303;&#x56F4;&#x662F;0&#xFF5E;30&#xFF0C;&#x4F46;&#x4E0D;&#x5F97;&#x8D85;&#x8FC7;M&#x3002;<br>
&#x6BD4;&#x5982; DECIMAL(6,2)&#x6700;&#x591A;&#x5B58;6&#x4F4D;&#x6570;&#x5B57;&#xFF0C;&#x5C0F;&#x6570;&#x70B9;&#x540E;&#x5360;2&#x4F4D;,&#x53D6;&#x503C;&#x8303;&#x56F4;-9999.99&#x5230;9999.99&#x3002;</p>
</blockquote>
</blockquote>
<blockquote>
<p>&#x6BD4;&#x7279;&#x503C;&#x7C7B;&#x578B;&#x6307;0&#xFF0C;1&#x503C;&#x8868;&#x8FBE;2&#x79CD;&#x60C5;&#x51B5;&#xFF0C;&#x5982;&#x771F;&#xFF0C;&#x5047;</p>
</blockquote>
<hr>
<blockquote>
<p>&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;&#xFF1A;</p>
<blockquote>
<p>CHAR&#x548C;VARCHAR&#x7C7B;&#x578B;<br>
BLOB&#x548C;TEXT&#x7C7B;&#x578B;<br>
ENUM&#x7C7B;&#x578B;&#x548C;SET&#x7C7B;&#x578B;</p>
</blockquote>
</blockquote>
<p><img src="img/%E5%AD%97%E7%AC%A6%E4%B8%B2.png" alt></p>
<ul>
<li>char &#x548C; varchar</li>
</ul>
<blockquote>
<p>char&#xFF1A;&#x5B9A;&#x957F;&#xFF0C;&#x6548;&#x7387;&#x9AD8;&#xFF0C;&#x4E00;&#x822C;&#x7528;&#x4E8E;&#x56FA;&#x5B9A;&#x957F;&#x5EA6;&#x7684;&#x8868;&#x5355;&#x63D0;&#x4EA4;&#x6570;&#x636E;&#x5B58;&#x50A8;&#xFF0C;&#x9ED8;&#x8BA4;1&#x5B57;&#x7B26;<br>
varchar&#xFF1A;&#x4E0D;&#x5B9A;&#x957F;&#xFF0C;&#x6548;&#x7387;&#x504F;&#x4F4E; &#xFF0C;&#x4F46;&#x662F;&#x8282;&#x7701;&#x7A7A;&#x95F4;&#x3002;</p>
</blockquote>
<ul>
<li>text &#x548C;blob</li>
</ul>
<blockquote>
<p>text&#x7528;&#x6765;&#x5B58;&#x50A8;&#x975E;&#x4E8C;&#x8FDB;&#x5236;&#x6587;&#x672C;<br>
blob&#x7528;&#x6765;&#x5B58;&#x50A8;&#x4E8C;&#x8FDB;&#x5236;&#x5B57;&#x8282;&#x4E32;</p>
</blockquote>
<ul>
<li>enum &#x548C; set</li>
</ul>
<blockquote>
<p>enum&#x7528;&#x6765;&#x5B58;&#x50A8;&#x7ED9;&#x51FA;&#x7684;&#x4E00;&#x4E2A;&#x503C;<br>
set&#x7528;&#x6765;&#x5B58;&#x50A8;&#x7ED9;&#x51FA;&#x7684;&#x503C;&#x4E2D;&#x4E00;&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x503C;</p>
</blockquote>
<hr>
<ol>
<li>&#x8868;&#x7684;&#x57FA;&#x672C;&#x64CD;&#x4F5C;</li>
</ol>
<blockquote>
<p>&#x521B;&#x5EFA;&#x8868;(&#x6307;&#x5B9A;&#x5B57;&#x7B26;&#x96C6;)</p>
<blockquote>
<p>create table &#x8868;&#x540D;(<br>
&#x5B57;&#x6BB5;&#x540D; &#x6570;&#x636E;&#x7C7B;&#x578B;,<br>
&#x5B57;&#x6BB5;&#x540D; &#x6570;&#x636E;&#x7C7B;&#x578B;,<br>
...<br>
&#x5B57;&#x6BB5;&#x540D; &#x6570;&#x636E;&#x7C7B;&#x578B;<br>
);</p>
</blockquote>
</blockquote>
<blockquote>
<blockquote>
<ul>
<li>&#x5982;&#x679C;&#x4F60;&#x60F3;&#x8BBE;&#x7F6E;&#x6570;&#x5B57;&#x4E3A;&#x65E0;&#x7B26;&#x53F7;&#x5219;&#x52A0;&#x4E0A; unsigned</li>
<li>&#x5982;&#x679C;&#x4F60;&#x4E0D;&#x60F3;&#x5B57;&#x6BB5;&#x4E3A; NULL &#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x5B57;&#x6BB5;&#x7684;&#x5C5E;&#x6027;&#x4E3A; NOT NULL&#xFF0C; &#x5728;&#x64CD;&#x4F5C;&#x6570;&#x636E;&#x5E93;&#x65F6;&#x5982;&#x679C;&#x8F93;&#x5165;&#x8BE5;&#x5B57;&#x6BB5;&#x7684;&#x6570;&#x636E;&#x4E3A;NULL &#xFF0C;&#x5C31;&#x4F1A;&#x62A5;&#x9519;&#x3002;</li>
<li>DEFAULT &#x8868;&#x793A;&#x8BBE;&#x7F6E;&#x4E00;&#x4E2A;&#x5B57;&#x6BB5;&#x7684;&#x9ED8;&#x8BA4;&#x503C;</li>
<li>AUTO_INCREMENT&#x5B9A;&#x4E49;&#x5217;&#x4E3A;&#x81EA;&#x589E;&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x4E00;&#x822C;&#x7528;&#x4E8E;&#x4E3B;&#x952E;&#xFF0C;&#x6570;&#x503C;&#x4F1A;&#x81EA;&#x52A8;&#x52A0;1&#x3002;</li>
<li>PRIMARY KEY&#x5173;&#x952E;&#x5B57;&#x7528;&#x4E8E;&#x5B9A;&#x4E49;&#x5217;&#x4E3A;&#x4E3B;&#x952E;&#x3002;&#x4E3B;&#x952E;&#x7684;&#x503C;&#x4E0D;&#x80FD;&#x91CD;&#x590D;&#x3002;</li>
</ul>
</blockquote>
</blockquote>
<pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span>  &#x521B;&#x5EFA;&#x73ED;&#x7EA7;&#x8868;
<span class="token keyword">create</span> <span class="token keyword">table</span> class_1 <span class="token punctuation">(</span>id <span class="token keyword">int</span> <span class="token keyword">primary</span> <span class="token keyword">key</span> <span class="token keyword">auto_increment</span><span class="token punctuation">,</span>name <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">32</span><span class="token punctuation">)</span> <span class="token operator">not</span> <span class="token boolean">null</span><span class="token punctuation">,</span>age <span class="token keyword">int</span> <span class="token keyword">unsigned</span> <span class="token operator">not</span> <span class="token boolean">null</span><span class="token punctuation">,</span>sex <span class="token keyword">enum</span><span class="token punctuation">(</span><span class="token string">&apos;w&apos;</span><span class="token punctuation">,</span><span class="token string">&apos;m&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>score <span class="token keyword">float</span> <span class="token keyword">default</span> <span class="token number">0.0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

e<span class="token punctuation">.</span>g<span class="token punctuation">.</span> &#x521B;&#x5EFA;&#x5174;&#x8DA3;&#x73ED;&#x8868;
<span class="token keyword">create</span> <span class="token keyword">table</span> interest <span class="token punctuation">(</span>id <span class="token keyword">int</span> <span class="token keyword">primary</span> <span class="token keyword">key</span> <span class="token keyword">auto_increment</span><span class="token punctuation">,</span>name <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">32</span><span class="token punctuation">)</span> <span class="token operator">not</span> <span class="token boolean">null</span><span class="token punctuation">,</span>hobby <span class="token keyword">set</span><span class="token punctuation">(</span><span class="token string">&apos;sing&apos;</span><span class="token punctuation">,</span><span class="token string">&apos;dance&apos;</span><span class="token punctuation">,</span><span class="token string">&apos;draw&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token keyword">level</span> <span class="token keyword">char</span> <span class="token operator">not</span> <span class="token boolean">null</span><span class="token punctuation">,</span>price <span class="token keyword">decimal</span><span class="token punctuation">(</span><span class="token number">6</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token keyword">comment</span> <span class="token keyword">text</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</pre><blockquote>
<p>&#x67E5;&#x770B;&#x6570;&#x636E;&#x8868;</p>
<blockquote>
<p>show tables&#xFF1B;</p>
</blockquote>
</blockquote>
<blockquote>
<p>&#x67E5;&#x770B;&#x5DF2;&#x6709;&#x8868;&#x7684;&#x5B57;&#x7B26;&#x96C6;</p>
<blockquote>
<p>show create table &#x8868;&#x540D;;</p>
</blockquote>
</blockquote>
<blockquote>
<p>&#x67E5;&#x770B;&#x8868;&#x7ED3;&#x6784;</p>
<blockquote>
<p>desc &#x8868;&#x540D;;</p>
</blockquote>
</blockquote>
<blockquote>
<p>&#x5220;&#x9664;&#x8868;</p>
<blockquote>
<p>drop table &#x8868;&#x540D;;</p>
</blockquote>
</blockquote>
<h2 class="mume-header" id="%E6%95%B0%E6%8D%AE%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C">&#x6570;&#x636E;&#x57FA;&#x672C;&#x64CD;&#x4F5C;</h2>

<h3 class="mume-header" id="%E6%8F%92%E5%85%A5insert">&#x63D2;&#x5165;(insert)</h3>

<pre data-role="codeBlock" data-info="SQL" class="language-sql"><span class="token keyword">insert</span> <span class="token keyword">into</span> &#x8868;&#x540D; <span class="token keyword">values</span><span class="token punctuation">(</span>&#x503C;<span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span>&#x503C;<span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">;</span>
<span class="token keyword">insert</span> <span class="token keyword">into</span> &#x8868;&#x540D;<span class="token punctuation">(</span>&#x5B57;&#x6BB5;<span class="token number">1</span><span class="token punctuation">,</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span> <span class="token keyword">values</span><span class="token punctuation">(</span>&#x503C;<span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">;</span>
</pre><pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span> 
<span class="token keyword">insert</span> <span class="token keyword">into</span> class_1 <span class="token keyword">values</span> <span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token string">&apos;Baron&apos;</span><span class="token punctuation">,</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token string">&apos;m&apos;</span><span class="token punctuation">,</span><span class="token number">91</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token string">&apos;Jame&apos;</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">,</span><span class="token string">&apos;m&apos;</span><span class="token punctuation">,</span><span class="token number">90</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</pre><h3 class="mume-header" id="%E6%9F%A5%E8%AF%A2select">&#x67E5;&#x8BE2;(select)</h3>

<pre data-role="codeBlock" data-info="SQL" class="language-sql"><span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> &#x8868;&#x540D; <span class="token punctuation">[</span><span class="token keyword">where</span> &#x6761;&#x4EF6;<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">select</span> &#x5B57;&#x6BB5;<span class="token number">1</span><span class="token punctuation">,</span>&#x5B57;&#x6BB5;&#x540D;<span class="token number">2</span> <span class="token keyword">from</span> &#x8868;&#x540D; <span class="token punctuation">[</span><span class="token keyword">where</span> &#x6761;&#x4EF6;<span class="token punctuation">]</span><span class="token punctuation">;</span>
</pre><pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span> 
<span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> class_1<span class="token punctuation">;</span>

<span class="token keyword">select</span> name<span class="token punctuation">,</span>age <span class="token keyword">from</span> class_1<span class="token punctuation">;</span>
</pre><h3 class="mume-header" id="where%E5%AD%90%E5%8F%A5">where&#x5B50;&#x53E5;</h3>

<p>where&#x5B50;&#x53E5;&#x5728;sql&#x8BED;&#x53E5;&#x4E2D;&#x626E;&#x6F14;&#x4E86;&#x91CD;&#x8981;&#x89D2;&#x8272;&#xFF0C;&#x4E3B;&#x8981;&#x901A;&#x8FC7;&#x4E00;&#x5B9A;&#x7684;&#x8FD0;&#x7B97;&#x6761;&#x4EF6;&#x8FDB;&#x884C;&#x6570;&#x636E;&#x7684;&#x7B5B;&#x9009;</p>
<p>MySQL &#x4E3B;&#x8981;&#x6709;&#x4EE5;&#x4E0B;&#x51E0;&#x79CD;&#x8FD0;&#x7B97;&#x7B26;&#xFF1A;</p>
<blockquote>
<p>&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;<br>
&#x6BD4;&#x8F83;&#x8FD0;&#x7B97;&#x7B26;<br>
&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;<br>
&#x4F4D;&#x8FD0;&#x7B97;&#x7B26;</p>
</blockquote>
<h4 class="mume-header" id="%E7%AE%97%E6%95%B0%E8%BF%90%E7%AE%97%E7%AC%A6">&#x7B97;&#x6570;&#x8FD0;&#x7B97;&#x7B26;</h4>

<p><img src="img/%E7%AE%97%E6%95%B0.png" alt></p>
<pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span>
<span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> class_1 <span class="token keyword">where</span> age <span class="token operator">%</span> <span class="token number">2</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
</pre><h4 class="mume-header" id="%E6%AF%94%E8%BE%83%E8%BF%90%E7%AE%97%E7%AC%A6">&#x6BD4;&#x8F83;&#x8FD0;&#x7B97;&#x7B26;</h4>

<p><img src="img/%E6%AF%94%E8%BE%83.png" alt></p>
<pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span>
<span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> class_1 <span class="token keyword">where</span> age <span class="token operator">&gt;</span> <span class="token number">8</span><span class="token punctuation">;</span>
<span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> class_1 <span class="token keyword">where</span> <span class="token operator">between</span> <span class="token number">8</span> <span class="token operator">and</span> <span class="token number">10</span><span class="token punctuation">;</span>
<span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> class_1 <span class="token keyword">where</span> age <span class="token operator">in</span> <span class="token punctuation">(</span><span class="token number">8</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</pre><h4 class="mume-header" id="%E9%80%BB%E8%BE%91%E8%BF%90%E7%AE%97%E7%AC%A6">&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;</h4>

<p><img src="img/%E9%80%BB%E8%BE%91.png" alt></p>
<pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span>
<span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> class_1 <span class="token keyword">where</span> sex<span class="token operator">=</span><span class="token string">&apos;m&apos;</span> <span class="token operator">and</span> age<span class="token operator">&gt;</span><span class="token number">9</span><span class="token punctuation">;</span>
</pre><h4 class="mume-header" id="%E4%BD%8D%E8%BF%90%E7%AE%97%E7%AC%A6">&#x4F4D;&#x8FD0;&#x7B97;&#x7B26;</h4>

<p><img src="img/%E4%BD%8D.png" alt></p>
<p><img src="img/%E8%BF%90%E7%AE%97%E7%AC%A6.png" alt></p>
<h3 class="mume-header" id="%E6%9B%B4%E6%96%B0%E8%A1%A8%E8%AE%B0%E5%BD%95update">&#x66F4;&#x65B0;&#x8868;&#x8BB0;&#x5F55;(update)</h3>

<pre data-role="codeBlock" data-info="SQL" class="language-sql"><span class="token keyword">update</span> &#x8868;&#x540D; <span class="token keyword">set</span> &#x5B57;&#x6BB5;<span class="token number">1</span><span class="token operator">=</span>&#x503C;<span class="token number">1</span><span class="token punctuation">,</span>&#x5B57;&#x6BB5;<span class="token number">2</span><span class="token operator">=</span>&#x503C;<span class="token number">2</span><span class="token punctuation">,</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">where</span> &#x6761;&#x4EF6;<span class="token punctuation">;</span>
</pre><pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span>
<span class="token keyword">update</span> class_1 <span class="token keyword">set</span> age<span class="token operator">=</span><span class="token number">11</span> <span class="token keyword">where</span> name<span class="token operator">=</span><span class="token string">&apos;Abby&apos;</span><span class="token punctuation">;</span>
</pre><h3 class="mume-header" id="%E5%88%A0%E9%99%A4%E8%A1%A8%E8%AE%B0%E5%BD%95delete">&#x5220;&#x9664;&#x8868;&#x8BB0;&#x5F55;&#xFF08;delete&#xFF09;</h3>

<pre data-role="codeBlock" data-info="SQL" class="language-sql"><span class="token keyword">delete</span> <span class="token keyword">from</span> &#x8868;&#x540D; <span class="token keyword">where</span> &#x6761;&#x4EF6;<span class="token punctuation">;</span>

&#x6CE8;&#x610F;:<span class="token keyword">delete</span>&#x8BED;&#x53E5;&#x540E;&#x5982;&#x679C;&#x4E0D;&#x52A0;<span class="token keyword">where</span>&#x6761;&#x4EF6;<span class="token punctuation">,</span>&#x6240;&#x6709;&#x8BB0;&#x5F55;&#x5168;&#x90E8;&#x6E05;&#x7A7A;
</pre><pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span>
<span class="token keyword">delete</span> <span class="token keyword">from</span> class_1 <span class="token keyword">where</span> name<span class="token operator">=</span><span class="token string">&apos;Abby&apos;</span><span class="token punctuation">;</span>
</pre><h3 class="mume-header" id="%E8%A1%A8%E5%AD%97%E6%AE%B5%E7%9A%84%E6%93%8D%E4%BD%9Calter">&#x8868;&#x5B57;&#x6BB5;&#x7684;&#x64CD;&#x4F5C;(alter)</h3>

<pre data-role="codeBlock" data-info="SQL" class="language-sql">&#x8BED;&#x6CD5; &#xFF1A;<span class="token keyword">alter</span> <span class="token keyword">table</span> &#x8868;&#x540D; &#x6267;&#x884C;&#x52A8;&#x4F5C;<span class="token punctuation">;</span>

<span class="token operator">*</span> &#x6DFB;&#x52A0;&#x5B57;&#x6BB5;<span class="token punctuation">(</span><span class="token keyword">add</span><span class="token punctuation">)</span>
    <span class="token keyword">alter</span> <span class="token keyword">table</span> &#x8868;&#x540D; <span class="token keyword">add</span> &#x5B57;&#x6BB5;&#x540D; &#x6570;&#x636E;&#x7C7B;&#x578B;<span class="token punctuation">;</span>
    <span class="token keyword">alter</span> <span class="token keyword">table</span> &#x8868;&#x540D; <span class="token keyword">add</span> &#x5B57;&#x6BB5;&#x540D; &#x6570;&#x636E;&#x7C7B;&#x578B; <span class="token keyword">first</span><span class="token punctuation">;</span>
    <span class="token keyword">alter</span> <span class="token keyword">table</span> &#x8868;&#x540D; <span class="token keyword">add</span> &#x5B57;&#x6BB5;&#x540D; &#x6570;&#x636E;&#x7C7B;&#x578B; <span class="token keyword">after</span> &#x5B57;&#x6BB5;&#x540D;<span class="token punctuation">;</span>
<span class="token operator">*</span> &#x5220;&#x9664;&#x5B57;&#x6BB5;<span class="token punctuation">(</span><span class="token keyword">drop</span><span class="token punctuation">)</span>
    <span class="token keyword">alter</span> <span class="token keyword">table</span> &#x8868;&#x540D; <span class="token keyword">drop</span> &#x5B57;&#x6BB5;&#x540D;<span class="token punctuation">;</span>
<span class="token operator">*</span> &#x4FEE;&#x6539;&#x6570;&#x636E;&#x7C7B;&#x578B;<span class="token punctuation">(</span><span class="token keyword">modify</span><span class="token punctuation">)</span>
    <span class="token keyword">alter</span> <span class="token keyword">table</span> &#x8868;&#x540D; <span class="token keyword">modify</span> &#x5B57;&#x6BB5;&#x540D; &#x65B0;&#x6570;&#x636E;&#x7C7B;&#x578B;<span class="token punctuation">;</span>
<span class="token operator">*</span> &#x4FEE;&#x6539;&#x5B57;&#x6BB5;&#x540D;<span class="token punctuation">(</span>change<span class="token punctuation">)</span>
    <span class="token keyword">alter</span> <span class="token keyword">table</span> &#x8868;&#x540D; change &#x65E7;&#x5B57;&#x6BB5;&#x540D; &#x65B0;&#x5B57;&#x6BB5;&#x540D; &#x65B0;&#x6570;&#x636E;&#x7C7B;&#x578B;<span class="token punctuation">;</span>
<span class="token operator">*</span> &#x8868;&#x91CD;&#x547D;&#x540D;<span class="token punctuation">(</span><span class="token keyword">rename</span><span class="token punctuation">)</span>
    <span class="token keyword">alter</span> <span class="token keyword">table</span> &#x8868;&#x540D; <span class="token keyword">rename</span> &#x65B0;&#x8868;&#x540D;<span class="token punctuation">;</span>
</pre><pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span> 
<span class="token keyword">alter</span> <span class="token keyword">table</span> interest <span class="token keyword">add</span> tel <span class="token keyword">char</span><span class="token punctuation">(</span><span class="token number">11</span><span class="token punctuation">)</span> <span class="token keyword">after</span> name<span class="token punctuation">;</span>
</pre><h3 class="mume-header" id="%E6%97%B6%E9%97%B4%E7%B1%BB%E5%9E%8B%E6%95%B0%E6%8D%AE">&#x65F6;&#x95F4;&#x7C7B;&#x578B;&#x6570;&#x636E;</h3>

<blockquote>
<p>&#x65F6;&#x95F4;&#x548C;&#x65E5;&#x671F;&#x7C7B;&#x578B;:</p>
<blockquote>
<p>DATE&#xFF0C;DATETIME&#x548C;TIMESTAMP&#x7C7B;&#x578B;<br>
TIME&#x7C7B;&#x578B;<br>
&#x5E74;&#x4EFD;&#x7C7B;&#x578B;YEAR</p>
</blockquote>
</blockquote>
<p><img src="img/%E6%97%B6%E9%97%B4.png" alt></p>
<h4 class="mume-header" id="%E6%97%B6%E9%97%B4%E6%A0%BC%E5%BC%8F">&#x65F6;&#x95F4;&#x683C;&#x5F0F;</h4>

<blockquote>
<p>date &#xFF1A;&quot;YYYY-MM-DD&quot;<br>
time &#xFF1A;&quot;HH:MM:SS&quot;<br>
datetime &#xFF1A;&quot;YYYY-MM-DD HH:MM:SS&quot;<br>
timestamp &#xFF1A;&quot;YYYY-MM-DD HH:MM:SS&quot;<br>
&#x6CE8;&#x610F;<br>
1&#x3001;datetime &#xFF1A;&#x4EE5;&#x7CFB;&#x7EDF;&#x65F6;&#x95F4;&#x5B58;&#x50A8;<br>
2&#x3001;timestamp &#xFF1A;&#x4EE5;&#x6807;&#x51C6;&#x65F6;&#x95F4;&#x5B58;&#x50A8;&#x4F46;&#x662F;&#x67E5;&#x770B;&#x65F6;&#x8F6C;&#x6362;&#x4E3A;&#x7CFB;&#x7EDF;&#x65F6;&#x533A;&#xFF0C;&#x6240;&#x4EE5;&#x8868;&#x73B0;&#x5F62;&#x5F0F;&#x548C;datetime&#x76F8;&#x540C;</p>
</blockquote>
<pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span>
<span class="token keyword">create</span> <span class="token keyword">table</span> marathon <span class="token punctuation">(</span>id <span class="token keyword">int</span> <span class="token keyword">primary</span> <span class="token keyword">key</span> <span class="token keyword">auto_increment</span><span class="token punctuation">,</span>athlete <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">32</span><span class="token punctuation">)</span><span class="token punctuation">,</span>birthday <span class="token keyword">date</span><span class="token punctuation">,</span>registration_time <span class="token keyword">datetime</span><span class="token punctuation">,</span>performance <span class="token keyword">time</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</pre><h4 class="mume-header" id="%E6%97%A5%E6%9C%9F%E6%97%B6%E9%97%B4%E5%87%BD%E6%95%B0">&#x65E5;&#x671F;&#x65F6;&#x95F4;&#x51FD;&#x6570;</h4>

<ul>
<li>now()  &#x8FD4;&#x56DE;&#x670D;&#x52A1;&#x5668;&#x5F53;&#x524D;&#x65F6;&#x95F4;,&#x683C;&#x5F0F;&#x5BF9;&#x5E94;datetime&#x7C7B;&#x578B;</li>
<li>curdate() &#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x65E5;&#x671F;&#xFF0C;&#x683C;&#x5F0F;&#x5BF9;&#x5E94;date&#x7C7B;&#x578B;</li>
<li>curtime() &#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x65F6;&#x95F4;&#xFF0C;&#x683C;&#x5F0F;&#x5BF9;&#x5E94;time&#x7C7B;&#x578B;</li>
</ul>
<h4 class="mume-header" id="%E6%97%B6%E9%97%B4%E6%93%8D%E4%BD%9C">&#x65F6;&#x95F4;&#x64CD;&#x4F5C;</h4>

<ul>
<li>&#x67E5;&#x627E;&#x64CD;&#x4F5C;</li>
</ul>
<pre data-role="codeBlock" data-info="sql" class="language-sql">  <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> marathon <span class="token keyword">where</span> birthday<span class="token operator">&gt;=</span><span class="token string">&apos;2000-01-01&apos;</span><span class="token punctuation">;</span>
  <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> marathon <span class="token keyword">where</span> birthday<span class="token operator">&gt;=</span><span class="token string">&quot;2000-07-01&quot;</span> <span class="token operator">and</span> performance<span class="token operator">&lt;=</span><span class="token string">&quot;2:30:00&quot;</span><span class="token punctuation">;</span>
</pre><ul>
<li>
<p>&#x65E5;&#x671F;&#x65F6;&#x95F4;&#x8FD0;&#x7B97;</p>
<ul>
<li>
<p>&#x8BED;&#x6CD5;&#x683C;&#x5F0F;</p>
<p>select * from &#x8868;&#x540D;  where &#x5B57;&#x6BB5;&#x540D; &#x8FD0;&#x7B97;&#x7B26; (&#x65F6;&#x95F4;-interval &#x65F6;&#x95F4;&#x95F4;&#x9694;&#x5355;&#x4F4D;);</p>
</li>
<li>
<p>&#x65F6;&#x95F4;&#x95F4;&#x9694;&#x5355;&#x4F4D;&#xFF1A;   2 hour | 1 minute | 2 second | 2 year | 3 month |  1 day</p>
</li>
</ul>
</li>
</ul>
<pre data-role="codeBlock" data-info="sql" class="language-sql">  <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> marathon <span class="token keyword">where</span> registration_time <span class="token operator">&gt;</span> <span class="token punctuation">(</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-</span><span class="token keyword">interval</span> <span class="token number">7</span> <span class="token keyword">day</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</pre><h3 class="mume-header" id="%E9%AB%98%E7%BA%A7%E6%9F%A5%E8%AF%A2%E8%AF%AD%E5%8F%A5">&#x9AD8;&#x7EA7;&#x67E5;&#x8BE2;&#x8BED;&#x53E5;</h3>

<h4 class="mume-header" id="%E6%A8%A1%E7%B3%8A%E6%9F%A5%E8%AF%A2%E5%92%8C%E6%AD%A3%E5%88%99%E6%9F%A5%E8%AF%A2">&#x6A21;&#x7CCA;&#x67E5;&#x8BE2;&#x548C;&#x6B63;&#x5219;&#x67E5;&#x8BE2;</h4>

<p>LIKE&#x7528;&#x4E8E;&#x5728;where&#x5B50;&#x53E5;&#x4E2D;&#x8FDB;&#x884C;&#x6A21;&#x7CCA;&#x67E5;&#x8BE2;&#xFF0C;SQL LIKE &#x5B50;&#x53E5;&#x4E2D;&#x4F7F;&#x7528;&#x767E;&#x5206;&#x53F7; %&#x6765;&#x8868;&#x793A;&#x4EFB;&#x610F;0&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x5B57;&#x7B26;&#xFF0C;&#x4E0B;&#x5212;&#x7EBF;_&#x8868;&#x793A;&#x4EFB;&#x610F;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x3002;</p>
<p>&#x4F7F;&#x7528; LIKE &#x5B50;&#x53E5;&#x4ECE;&#x6570;&#x636E;&#x8868;&#x4E2D;&#x8BFB;&#x53D6;&#x6570;&#x636E;&#x7684;&#x901A;&#x7528;&#x8BED;&#x6CD5;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="sql" class="language-sql"><span class="token keyword">SELECT</span> field1<span class="token punctuation">,</span> field2<span class="token punctuation">,</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>fieldN 
<span class="token keyword">FROM</span> table_name
<span class="token keyword">WHERE</span> field1 <span class="token operator">LIKE</span> condition1
</pre><pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span> 
mysql<span class="token operator">&gt;</span> <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> class_1 <span class="token keyword">where</span> name <span class="token operator">like</span> <span class="token string">&apos;A%&apos;</span><span class="token punctuation">;</span>
</pre><p>mysql&#x4E2D;&#x5BF9;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x652F;&#x6301;&#x6709;&#x9650;&#xFF0C;&#x53EA;&#x652F;&#x6301;&#x90E8;&#x5206;&#x6B63;&#x5219;&#x5143;&#x5B57;&#x7B26;</p>
<pre data-role="codeBlock" data-info="sql" class="language-sql"><span class="token keyword">SELECT</span> field1<span class="token punctuation">,</span> field2<span class="token punctuation">,</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>fieldN 
<span class="token keyword">FROM</span> table_name
<span class="token keyword">WHERE</span> field1 <span class="token operator">REGEXP</span> condition1
</pre><pre data-role="codeBlock" data-info="sql" class="language-sql">e<span class="token punctuation">.</span>g<span class="token punctuation">.</span> 
<span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> class_1 <span class="token keyword">where</span> name <span class="token operator">regexp</span> <span class="token string">&apos;^B.+&apos;</span><span class="token punctuation">;</span>
</pre><h4 class="mume-header" id="%E6%8E%92%E5%BA%8F">&#x6392;&#x5E8F;</h4>

<p>ORDER BY &#x5B50;&#x53E5;&#x6765;&#x8BBE;&#x5B9A;&#x4F60;&#x60F3;&#x6309;&#x54EA;&#x4E2A;&#x5B57;&#x6BB5;&#x54EA;&#x79CD;&#x65B9;&#x5F0F;&#x6765;&#x8FDB;&#x884C;&#x6392;&#x5E8F;&#xFF0C;&#x518D;&#x8FD4;&#x56DE;&#x641C;&#x7D22;&#x7ED3;&#x679C;&#x3002;</p>
<p>&#x4F7F;&#x7528; ORDER BY &#x5B50;&#x53E5;&#x5C06;&#x67E5;&#x8BE2;&#x6570;&#x636E;&#x6392;&#x5E8F;&#x540E;&#x518D;&#x8FD4;&#x56DE;&#x6570;&#x636E;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="sql" class="language-sql"><span class="token keyword">SELECT</span> field1<span class="token punctuation">,</span> field2<span class="token punctuation">,</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>fieldN <span class="token keyword">from</span> table_name1 <span class="token keyword">where</span> field1
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> field1 <span class="token punctuation">[</span><span class="token keyword">ASC</span> <span class="token punctuation">[</span><span class="token keyword">DESC</span><span class="token punctuation">]</span><span class="token punctuation">]</span>
</pre><p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;ASC&#x8868;&#x793A;&#x5347;&#x5E8F;&#xFF0C;DESC&#x8868;&#x793A;&#x964D;&#x5E8F;</p>
<pre data-role="codeBlock" data-info="sql" class="language-sql"><span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> class_1 <span class="token keyword">where</span> sex<span class="token operator">=</span><span class="token string">&apos;m&apos;</span> <span class="token keyword">order</span> <span class="token keyword">by</span> age<span class="token punctuation">;</span>
</pre><h4 class="mume-header" id="%E5%88%86%E9%A1%B5%E9%99%90%E5%88%B6">&#x5206;&#x9875;(&#x9650;&#x5236;)</h4>

<p>LIMIT &#x5B50;&#x53E5;&#x7528;&#x4E8E;&#x9650;&#x5236;&#x7531; SELECT &#x8BED;&#x53E5;&#x8FD4;&#x56DE;&#x7684;&#x6570;&#x636E;&#x6570;&#x91CF; &#x6216;&#x8005; UPDATE,DELETE&#x8BED;&#x53E5;&#x7684;&#x64CD;&#x4F5C;&#x6570;&#x91CF;</p>
<p>&#x5E26;&#x6709; LIMIT &#x5B50;&#x53E5;&#x7684; SELECT &#x8BED;&#x53E5;&#x7684;&#x57FA;&#x672C;&#x8BED;&#x6CD5;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="sql" class="language-sql"><span class="token keyword">SELECT</span> column1<span class="token punctuation">,</span> column2<span class="token punctuation">,</span> columnN 
<span class="token keyword">FROM</span> table_name
<span class="token keyword">WHERE</span> field
<span class="token keyword">LIMIT</span> <span class="token punctuation">[</span>num<span class="token punctuation">]</span>
</pre><h4 class="mume-header" id="%E8%81%94%E5%90%88%E6%9F%A5%E8%AF%A2">&#x8054;&#x5408;&#x67E5;&#x8BE2;</h4>

<p>UNION &#x64CD;&#x4F5C;&#x7B26;&#x7528;&#x4E8E;&#x8FDE;&#x63A5;&#x4E24;&#x4E2A;&#x4EE5;&#x4E0A;&#x7684; SELECT &#x8BED;&#x53E5;&#x7684;&#x7ED3;&#x679C;&#x7EC4;&#x5408;&#x5230;&#x4E00;&#x4E2A;&#x7ED3;&#x679C;&#x96C6;&#x5408;&#x4E2D;&#x3002;&#x591A;&#x4E2A; SELECT &#x8BED;&#x53E5;&#x4F1A;&#x5220;&#x9664;&#x91CD;&#x590D;&#x7684;&#x6570;&#x636E;&#x3002;</p>
<p>UNION &#x64CD;&#x4F5C;&#x7B26;&#x8BED;&#x6CD5;&#x683C;&#x5F0F;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="sql" class="language-sql"><span class="token keyword">SELECT</span> expression1<span class="token punctuation">,</span> expression2<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> expression_n
<span class="token keyword">FROM</span> <span class="token keyword">tables</span>
<span class="token punctuation">[</span><span class="token keyword">WHERE</span> conditions<span class="token punctuation">]</span>
<span class="token keyword">UNION</span> <span class="token punctuation">[</span><span class="token keyword">ALL</span> <span class="token operator">|</span> <span class="token keyword">DISTINCT</span><span class="token punctuation">]</span>
<span class="token keyword">SELECT</span> expression1<span class="token punctuation">,</span> expression2<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> expression_n
<span class="token keyword">FROM</span> <span class="token keyword">tables</span>
<span class="token punctuation">[</span><span class="token keyword">WHERE</span> conditions<span class="token punctuation">]</span><span class="token punctuation">;</span>
</pre><blockquote>
<p>expression1, expression2, ... expression_n: &#x8981;&#x68C0;&#x7D22;&#x7684;&#x5217;&#x3002;<br>
tables: &#x8981;&#x68C0;&#x7D22;&#x7684;&#x6570;&#x636E;&#x8868;&#x3002;<br>
WHERE conditions: &#x53EF;&#x9009;&#xFF0C; &#x68C0;&#x7D22;&#x6761;&#x4EF6;&#x3002;<br>
DISTINCT: &#x53EF;&#x9009;&#xFF0C;&#x5220;&#x9664;&#x7ED3;&#x679C;&#x96C6;&#x4E2D;&#x91CD;&#x590D;&#x7684;&#x6570;&#x636E;&#x3002;&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B; UNION &#x64CD;&#x4F5C;&#x7B26;&#x5DF2;&#x7ECF;&#x5220;&#x9664;&#x4E86;&#x91CD;&#x590D;&#x6570;&#x636E;&#xFF0C;&#x6240;&#x4EE5; DISTINCT &#x4FEE;&#x9970;&#x7B26;&#x5BF9;&#x7ED3;&#x679C;&#x6CA1;&#x5565;&#x5F71;&#x54CD;&#x3002;<br>
ALL: &#x53EF;&#x9009;&#xFF0C;&#x8FD4;&#x56DE;&#x6240;&#x6709;&#x7ED3;&#x679C;&#x96C6;&#xFF0C;&#x5305;&#x542B;&#x91CD;&#x590D;&#x6570;&#x636E;&#x3002;</p>
</blockquote>
<pre data-role="codeBlock" data-info="sql" class="language-sql"><span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> class_1 <span class="token keyword">where</span> sex<span class="token operator">=</span><span class="token string">&apos;m&apos;</span> <span class="token keyword">UNION</span> <span class="token keyword">ALL</span> <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> class_1 <span class="token keyword">where</span> age <span class="token operator">&gt;</span> <span class="token number">9</span><span class="token punctuation">;</span>
</pre><h3 class="mume-header" id="%E6%95%B0%E6%8D%AE%E5%A4%87%E4%BB%BD">&#x6570;&#x636E;&#x5907;&#x4EFD;</h3>

<ol>
<li>&#x5907;&#x4EFD;&#x547D;&#x4EE4;&#x683C;&#x5F0F;</li>
</ol>
<blockquote>
<p>mysqldump -u&#x7528;&#x6237;&#x540D; -p &#x6E90;&#x5E93;&#x540D; &gt; ~/stu.sql</p>
<blockquote>
<p>--all-databases  &#x5907;&#x4EFD;&#x6240;&#x6709;&#x5E93;<br>
&#x5E93;&#x540D;             &#x5907;&#x4EFD;&#x5355;&#x4E2A;&#x5E93;<br>
-B &#x5E93;1 &#x5E93;2 &#x5E93;3   &#x5907;&#x4EFD;&#x591A;&#x4E2A;&#x5E93;<br>
&#x5E93;&#x540D; &#x8868;1 &#x8868;2 &#x8868;3 &#x5907;&#x4EFD;&#x6307;&#x5B9A;&#x5E93;&#x7684;&#x591A;&#x5F20;&#x8868;</p>
</blockquote>
</blockquote>
<ol start="2">
<li>&#x6062;&#x590D;&#x547D;&#x4EE4;&#x683C;&#x5F0F;</li>
</ol>
<blockquote>
<p>mysql -uroot -p &#x76EE;&#x6807;&#x5E93;&#x540D; &lt; stu.sql<br>
&#x4ECE;&#x6240;&#x6709;&#x5E93;&#x5907;&#x4EFD;&#x4E2D;&#x6062;&#x590D;&#x67D0;&#x4E00;&#x4E2A;&#x5E93;(--one-database)</p>
<blockquote>
<p>mysql -uroot -p --one-database &#x76EE;&#x6807;&#x5E93;&#x540D; &lt; all.sql</p>
</blockquote>
</blockquote>
<h2 class="mume-header" id="python%E6%93%8D%E4%BD%9Cmysql%E6%95%B0%E6%8D%AE%E5%BA%93">Python&#x64CD;&#x4F5C;MySQL&#x6570;&#x636E;&#x5E93;</h2>

<h3 class="mume-header" id="pymysql%E5%AE%89%E8%A3%85">pymysql&#x5B89;&#x88C5;</h3>

<blockquote>
<p>sudo pip3 install pymysql</p>
</blockquote>
<h3 class="mume-header" id="pymysql%E4%BD%BF%E7%94%A8%E6%B5%81%E7%A8%8B">pymysql&#x4F7F;&#x7528;&#x6D41;&#x7A0B;</h3>

<ol>
<li>&#x5EFA;&#x7ACB;&#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5;(db = pymysql.connect(...))</li>
<li>&#x521B;&#x5EFA;&#x6E38;&#x6807;&#x5BF9;&#x8C61;(cur = db.cursor())</li>
<li>&#x6E38;&#x6807;&#x65B9;&#x6CD5;: cur.execute(&quot;insert ....&quot;)</li>
<li>&#x63D0;&#x4EA4;&#x5230;&#x6570;&#x636E;&#x5E93;&#x6216;&#x8005;&#x83B7;&#x53D6;&#x6570;&#x636E; : db.commit()/db.fetchall()</li>
<li>&#x5173;&#x95ED;&#x6E38;&#x6807;&#x5BF9;&#x8C61; &#xFF1A;cur.close()</li>
<li>&#x65AD;&#x5F00;&#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5; &#xFF1A;db.close()</li>
</ol>
<h4 class="mume-header" id="%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0">&#x5E38;&#x7528;&#x51FD;&#x6570;</h4>

<p><em><strong>&#x53C2;&#x8003;&#x4EE3;&#x7801; day15/mysql.py</strong></em><br>
<em><strong>&#x53C2;&#x8003;&#x4EE3;&#x7801; day15/read_db.py</strong></em><br>
<em><strong>&#x53C2;&#x8003;&#x4EE3;&#x7801; day15/write_db.py</strong></em></p>
<blockquote>
<p>db = pymysql.connect(&#x53C2;&#x6570;&#x5217;&#x8868;)</p>
<blockquote>
<p>host &#xFF1A;&#x4E3B;&#x673A;&#x5730;&#x5740;,&#x672C;&#x5730; localhost<br>
port &#xFF1A;&#x7AEF;&#x53E3;&#x53F7;,&#x9ED8;&#x8BA4;3306<br>
user &#xFF1A;&#x7528;&#x6237;&#x540D;<br>
password &#xFF1A;&#x5BC6;&#x7801;<br>
database &#xFF1A;&#x5E93;<br>
charset &#xFF1A;&#x7F16;&#x7801;&#x65B9;&#x5F0F;,&#x63A8;&#x8350;&#x4F7F;&#x7528; utf8</p>
</blockquote>
</blockquote>
<blockquote>
<p>&#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5;&#x5BF9;&#x8C61;(db)&#x7684;&#x65B9;&#x6CD5;</p>
<blockquote>
<p>cur = db.cursor() &#x8FD4;&#x56DE;&#x6E38;&#x6807;&#x5BF9;&#x8C61;,&#x7528;&#x4E8E;&#x6267;&#x884C;&#x5177;&#x4F53;SQL&#x547D;&#x4EE4;<br>
db.commit() &#x63D0;&#x4EA4;&#x5230;&#x6570;&#x636E;&#x5E93;&#x6267;&#x884C;<br>
db.rollback() &#x56DE;&#x6EDA;&#xFF0C;&#x7528;&#x4E8E;&#x5F53;commit()&#x51FA;&#x9519;&#x662F;&#x56DE;&#x590D;&#x5230;&#x539F;&#x6765;&#x7684;&#x6570;&#x636E;&#x5F62;&#x6001;<br>
db.close() &#x5173;&#x95ED;&#x8FDE;&#x63A5;</p>
</blockquote>
</blockquote>
<blockquote>
<p>&#x6E38;&#x6807;&#x5BF9;&#x8C61;(cur)&#x7684;&#x65B9;&#x6CD5;</p>
<blockquote>
<p>cur.execute(sql&#x547D;&#x4EE4;,[&#x5217;&#x8868;]) &#x6267;&#x884C;SQL&#x547D;&#x4EE4;<br>
cur.fetchone() &#x83B7;&#x53D6;&#x67E5;&#x8BE2;&#x7ED3;&#x679C;&#x96C6;&#x7684;&#x7B2C;&#x4E00;&#x6761;&#x6570;&#x636E;&#xFF0C;&#x67E5;&#x627E;&#x5230;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5143;&#x7EC4;&#x5426;&#x5219;&#x8FD4;&#x56DE;None<br>
cur.fetchmany(n) &#x83B7;&#x53D6;&#x524D;n&#x6761;&#x67E5;&#x627E;&#x5230;&#x7684;&#x8BB0;&#x5F55;&#xFF0C;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x4E3A;&#x5143;&#x7EC4;&#x5D4C;&#x5957;&#x5143;&#x7EC4;&#xFF0C; ((&#x8BB0;&#x5F55;1),(&#x8BB0;&#x5F55;2))&#x3002;<br>
cur.fetchall() &#x83B7;&#x53D6;&#x6240;&#x6709;&#x67E5;&#x627E;&#x5230;&#x7684;&#x8BB0;&#x5F55;&#xFF0C;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x5F62;&#x5F0F;&#x540C;&#x4E0A;&#x3002;<br>
cur.close() &#x5173;&#x95ED;&#x6E38;&#x6807;&#x5BF9;&#x8C61;</p>
</blockquote>
</blockquote>

      </div>
      
      
    
    
    
    
    
    
    
    
  
    </body></html>